Repository navigation
Conversation
s3rius
approved these changes
Nov 18, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #728 +/- ##
==========================================
+ Coverage 86.06% 86.14% +0.07%
==========================================
Files 69 69
Lines 2778 2779 +1
==========================================
+ Hits 2391 2394 +3
+ Misses 387 385 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
gather()keys its pending set and result map only bytask_id, although eachAsyncTaskiqTaskalso carries its own result backend. When two independent backends contain the same custom task ID, one branch's result is returned for both positions. If only one backend has a result,gather()can report success while the other branch is still pending.This applies to explicit IDs reused in independent result stores, not random UUID collisions. It reproduces on upstream
1818f5381978eeea5825b7d32397fe8950f5eae3.Reproduction
The following runs without a worker service, network access, model, or credentials:
Before:
['research result', 'research result']After:
['research result', 'review result']For the premature-completion case, store only the left result and pass
timeout=0.01togather(). Before this change it still returns the duplicated successful result; afterwards it waits for the missing branch and raisesTaskiqResultTimeoutError. The tests also reproduce the wrong-result case through two realInMemoryBrokerinstances and the public task/kicker APIs.Fix
Key pending work and fetched results by
(id(task.result_backend), task.task_id). This preserves input ordering and fetches equivalent handles sharing the same backend instance only once, including backends that consume a result on read. The function signature, polling interval, and timeout clock are unchanged. The docstring now describes the identity contract.Backend identity is the Python object, not a physical store inferred from connection settings. Separate backend objects connected to the same physical store are treated independently; callers needing a single consuming read should share the backend instance.
Validation
Python 3.12.16, macOS arm64, repository lockfile dependencies:
python -m pytest -q).mypy taskiq tests: no issues in 147 source files.Coverage includes both input orders, either backend remaining pending, a result published after the initial poll, and duplicate handles with a consuming backend. No live Redis or model service was tested.
Related work
Rechecked open and closed
gatherPRs before submission. #711 addresses the final polling delay and #705 addresses timeout clock measurement; their patches do not address backend-scoped result identity. This change leaves those behaviors unchanged.